{{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals())}}
{{extend 'layout.html'}}

{{if 'message' in globals():}}
<h3>{{=message}}</h3>
{{pass}}

<h4>{{=T('Siūlomi žaidimai/mačai')}}</h4>

{{if len(joined_proposed_matches): }}
<p>Tu bandai jungtis prie {{=len(joined_proposed_matches)}} siūlomų mačų.</p>
{{pass}}

<table>
    {{=TR( map(TH, map(T, 'Žaidimas | Kada pasiūlyta | max laikas (minutėm) | Dalyviai'.split('|') ) ) ) }}
{{ for match in proposed_matches:
    is_joined = match.id in joined_proposed_matches
    match_actions = A(match.proposed, _href='join/%s'%match.id )
    if is_joined:
        match_actions = DIV(
                            B(match.proposed),
                            XML("[%s] " % proposed_maches_gameserver_links[match.id]),
                            XML("[%s] " % A(T('atsijungti'), _href='leave/%s'%match.id )),
                            )
    pass
    
    =TR( [match.game.name, match_actions, match.max_duration_in_minutes, ','.join(match.players_list) ] ) 
pass}}
</table>


<div>{{=A(T('Sukurti/pasiūlyti naują mačą'), _href='init')}}</div>

<div style="display:block; color: silver">

<hr />
<h4>{{=T('Vykstantys žaidimai')}}</h4>
<table>
    {{=TR( map(TH, map(T, 'Žaidimas | Kada pasiūlyta | Kada pradėta | max laikas (minutėm) | Dalyviai'.split('|') ) ) ) }}
{{ for match in ongoing_matches:
    game_link = ongoing_maches_gameserver_links.get(match.id, '')
    actions = DIV( XML("[%s] " % game_link) ,
                   XML("[%s] " % A(T('nutraukti/pasiduoti'), _href='leave/%s'%match.id ))
              ) if game_link else ''
              
    =TR( [match.game.name, match.proposed, DIV(match.started , actions), match.max_duration_in_minutes, ','.join(match.players_list) ] ) 
pass}}
</table>

<hr />
<h4>{{=T('Pasibaigę žaidimai')}}</h4>
<table>
    {{=TR( map(TH, map(T, 'Žaidimas | Kada pasiūlyta | Kada pasiūlyta | Kada baigta | Laimėtojas | Dalyviai'.split('|') ) ) ) }}
{{ for match in finished_matches: 
    =TR( [match.game.name, match.proposed, match.started, match.finished, match.winner.name if match.winner else '-', ','.join(match.players_list) ] ) 
pass}}
</table>

    <hr />
    <h4>Response Vars</h4>
    {{=BEAUTIFY(response._vars)}}
</div>
